package com.rul.mars.user.controller;

import com.rul.mars.common.api.CommonResult;
import com.rul.mars.user.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 管理员用户服务接口
 *
 * @author RuL
 */
@Api(tags = "AdminUserController", description = "管理员用户服务接口")
@RestController
@RequestMapping("/admin/user")
public class AdminUserController {

    @Autowired
    private UserService userService;

    /**
     * 禁用用户账号
     *
     * @param id 用户ID
     * @return 操作结果
     */
    @ApiOperation("禁用用户账号")
    @GetMapping("/disable")
    public CommonResult disableUser(@RequestParam("id") Long id) {
        boolean success = userService.disableUser(id);
        if (success) {
            return CommonResult.success();
        }
        return CommonResult.failed();
    }

    /**
     * 删除用户
     *
     * @param id 用户ID
     * @return 删除结果
     */
    @ApiOperation("删除用户")
    @GetMapping("/delete")
    public CommonResult deleteUser(@RequestParam("id") Long id) {
        boolean success = userService.deleteUser(id);
        if (success) {
            return CommonResult.success();
        }
        return CommonResult.failed();
    }

}
